package com.example.footballsystem.controller;

import com.example.footballsystem.entity.Book;
import com.example.footballsystem.entity.Field;
import com.example.footballsystem.service.BookService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/Book")
@CrossOrigin(origins = "*")
public class BookController {
    @Autowired
    BookService bookService;
    //获取全部预定信息
    @GetMapping("/getAllBook")
    public ResponseEntity<List<Book>> getAllBook(){
        return ResponseEntity.ok().body(bookService.getAllBook());
    }
    @GetMapping("/searchBook")
    public ResponseEntity<List<Book>> searchBook(String info){
        return ResponseEntity.ok().body(bookService.searchBook(info));
    }
    @PostMapping("/addBook")
    public ResponseEntity<Boolean> addBook(@RequestBody Book book){
        return ResponseEntity.ok().body(bookService.addBook(book));
    }
    @PostMapping("/deleteBook")
    public ResponseEntity<Boolean> deleteBook(@RequestBody Book book){
        return ResponseEntity.ok().body(bookService.deleteBook(book));
    }
}
